<?php
/**
 *   权限管理表管理
*/

namespace app\admin\controller;

use app\facade\Basic;
use think\Request;
use app\admin\service\Auth as ServiceAuth;

class Auth extends BaseController
{
    /**
     *  角色列表
    */
    public function list(Request $request)
    {
        $param['page'] = $request->param('pageIndex',1);

        /* 验证 */
        $this->validateData($param,'Auth.list');

       $Operator = new ServiceAuth();
       $result = $Operator->list($param);
        return Basic::json($result);
    }

    /**
     *  员工详情
    */
    public function detail(Request $request)
    {
        $param['id'] = $request->param('id',null);

        /* 验证 */
        $this->validateData($param,'Auth.detail');


        $Operator = new ServiceAuth();
        $result = $Operator->detail($param);
        return Basic::json($result);
    }


    /**
     *  员工信息更新
    */
    public function save(Request $request)
    {
        $param['operator_id'] = $request->operator_id;
        $param['id'] = $request->param('id',null);  // 权限表ID
        $param['module'] = $request->param('module',null); // 模块名称
        $param['authname'] = $request->param('authname',null); // 权限名称
        $param['route'] = $request->param('route',null); // 访问路径
        $param['remark'] = $request->param('remark',null); // 备注
        $param['parent_id'] = $request->param('parent_id',0); // 上级ID

        /* 验证 */
        $this->validateData($param,'Auth.save');

        $Operator = new ServiceAuth();
        $result = $Operator->save($param);
        return Basic::json($result);
    }


    /**
     *  删除角色
    */
    public function remove(Request $request)
    {
        $param['id'] = $request->param('id',null);

        /* 验证 */
        $this->validateData($param,'Auth.remove');

        $Operator = new ServiceAuth();
        $result = $Operator->remove($param);
        return Basic::json($result);

    }

    /**
     *  删除角色
    */
    public function del(Request $request)
    {
        $param['id'] = $request->param('id',null);

        /* 验证 */
        $this->validateData($param,'Auth.del');

        $Operator = new ServiceAuth();
        $result = $Operator->del($param);
        return Basic::json($result);
    }



}
